#!/usr/bin/env python
# -*- coding: utf-8 -*- 
#############################################################################
# GMangas
# Copyright (C) 2008  Ferraro Luciano (aka Lux) <luciano.ferraro@gmail.com>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
############################################################################

import pygtk
pygtk.require("2.0")
import gtk
import gtk.glade

class Main:
    def __init__(self, main, glade):
        self._ = {} 
        self.text = {"manga":"Select a Manga", "chapter":"Chapter",
                     "page":"Page"}
        for box in self.text.keys():
            value = glade.get_widget(box)
            setattr(self, box, value)
            self._[box] = [value, 0]
            value.set_active(0)

    def add_value(self, value, text):
        box = self._[text]
        box[0].append_text(value)
        box[1] += 1

    def clear(self, text):
        box = self._[text]
        if box[1] < 1:
            return None

        for num in xrange(box[1]+1):
            box[0].remove_text(0)
        box[1] = 0

        self.add_value(self.text[text], text)
        box[0].set_active(0)
